package com.itheima;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

public class ServletDemo6 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //创建servet对象
        ServletConfig sc = super.getServletConfig();
        //打印参数
        Enumeration<String> ip = sc.getInitParameterNames();
        while (ip.hasMoreElements()){
            String key = ip.nextElement();
            String value = sc.getInitParameter(key);
            System.out.println(key+","+value);
        }
        //获取servletcontex对象
        ServletContext servletContext = sc.getServletContext();
        System.out.println(servletContext);
    }
}
